﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using System.Web;
using System.Web.Security;
using System.Data;

namespace logic
{
    public class sysAdmin
    {
        public static int AdminID
        {
            get
            {
                return Convert.ToInt32(HttpContext.Current.User.Identity.Name);
            }
            set
            {
                FormsAuthentication.SetAuthCookie(value.ToString(),false);
            }
        }
        public static void RecordLogin(int id)
        {
            AdminID = id;
        }
        public static void logout()
        {
            FormsAuthentication.SignOut();
        }

        public static void insert(SysAdminEntity admin)
        {
            SysAdmin.insert(admin);
        }

        public static void update(SysAdminEntity admin)
        {
            SysAdmin.update(admin);
        }

        public static void delete(int sysId)
        {
            SysAdmin.delete(sysId);
        }

        public static bool isExistUser(string username)
        {
            return SysAdmin.isExistUser(username);
        }

        public static SysAdminEntity login(string username, string password,int disablemin)
        {
            return SysAdmin.login(username, password,disablemin);
        }

        public static SysAdminEntity getById(int sysId)
        {
            return SysAdmin.getById(sysId);
        }

        public static DataSet select(string where, string orderby, int pagesize, int pageindex)
        {
            return DAL.DbHelper.ExecuteDataSetPageSize("*", "[dbo].[vw_SysAdmin_list]", where, "adminId", orderby, pagesize, pageindex);
        }
        public static DataSet selectInseptor(string where, string orderby, int pagesize, int pageindex)
        {
            return DAL.DbHelper.ExecuteDataSetPageSize("*", "[dbo].[vw_InspectorChargeCompany_list]", where, "companyId", orderby, pagesize, pageindex);
        }
        public static DataSet selectWithOutInseptor(string where, string orderby, int pagesize, int pageindex)
        {
            return DAL.DbHelper.ExecuteDataSetPageSize("*", "[dbo].[vw_Company_listWithoutInspector]", where, "companyId", orderby, pagesize, pageindex);
        }
        public static void updatePwd(SysAdminEntity admin)
        {
            SysAdmin.updatePwd(admin);
        }
        public static void updatePermission(int adminId, string permission)
        {
            SysAdmin.updatePermission(adminId, permission);
        }
        public static DataTable listWithSalesperson()
        {
            return SysAdmin.listWithSalesperson();
        }

        public static void IsDisable(int adminid)
        {
            SysAdmin.IsDisable(adminid);
        }

        public static int selectPsdhistory(int username, string uType)
        {
            return SysAdmin.selectPsdhistory(username, uType);
        }

        public static void SendSMS(string phones, string content, int adminId, string url)
        {
            SysAdmin.SendSMS(phones, content, adminId, url);
        }

        public static void chargeSeller(int categoryId, int adminId, int companyId)
        {
            SysAdmin.chargeSeller(categoryId, adminId, companyId);
        }
        public static void chargeSellerDel(int pcsid)
        {
            SysAdmin.chargeSellerDel(pcsid);
        }

        /// <summary>
        /// 根据责任部门ID得到责任人
        /// </summary>
        /// <param name="departmentId"></param>
        /// <returns></returns>
        public static DataTable getBydepartmentId(int departmentId)
        {
            return SysAdmin.getBydepartmentId(departmentId);
        }
        public static void errorTimesToZero(int adminId)
        {
            SysAdmin.ErrorTimesToZero(adminId);
        }
    }
}
